﻿using System;

namespace TIFPDFCounter
{
	
	public class Dimension
	{
		public decimal Nominal { get; set; }
		public decimal Min { get; set; }
		public decimal Max { get; set; }
		public bool Compare(decimal value)
		{
			if (value >= Min && value <= Max)
				return true;
			return false;
		}
	}
	
	public class Size
	{
		public Size()
		{
			Width = new Dimension();
			Height = new Dimension();
		}
		public Dimension Width { get; set; }
		public Dimension Height { get; set; }
		public bool IsMatch(decimal width, decimal height)
		{
			if (Width.Compare(width) && Height.Compare(height))
				return true;
			
			// Swap orientation and compare again
			if (Width.Compare(height) && Height.Compare(width))
				return true;
			
			return false;
		}
	}
	
	public class Page
	{
		public Page()
		{
			Size = new Size();
		}
		public string Name { get; set; }
		public string NameWithSize
		{
			get
			{
				return string.Concat(Name, " [ ", Size.Width.Nominal.ToString(), " \u00d7 ", Size.Height.Nominal.ToString(), " ]");
			}
		}
		public Size Size { get; set; }
		public bool Active { get; set; }
		public decimal Variance { get; set; }
	}
}
